/*******************************************************************************
 * Size: 16 px
 * Bpp: 4
 * Opts: --bpp 4 --size 16 --no-compress --font OPlusSans3-Medium.ttf --symbols 0123456789 --format lvgl -o game_2048_font_16.c
 ******************************************************************************/

#ifdef LV_LVGL_H_INCLUDE_SIMPLE
#include "lvgl.h"
#else
#include "lvgl/lvgl.h"
#endif

#ifndef GAME_2048_FONT_16
#define GAME_2048_FONT_16 1
#endif

#if GAME_2048_FONT_16

/*-----------------
 *    BITMAPS
 *----------------*/

/*Store the image of the glyphs*/
static LV_ATTRIBUTE_LARGE_CONST const uint8_t glyph_bitmap[] = {
    /* U+0030 "0" */
    0x0, 0x3b, 0xff, 0xb3, 0x0, 0x2, 0xfe, 0x77,
    0xef, 0x20, 0xa, 0xf2, 0x0, 0x2f, 0xa0, 0xd,
    0xd0, 0x0, 0xd, 0xd0, 0xf, 0xb0, 0x0, 0xb,
    0xf0, 0xf, 0xb0, 0x0, 0xa, 0xf0, 0xf, 0xb0,
    0x0, 0xa, 0xf0, 0xf, 0xb0, 0x0, 0xb, 0xf0,
    0xd, 0xd0, 0x0, 0xd, 0xd0, 0x9, 0xf2, 0x0,
    0x2f, 0xa0, 0x1, 0xfe, 0x77, 0xef, 0x20, 0x0,
    0x3b, 0xff, 0xc3, 0x0,

    /* U+0031 "1" */
    0x0, 0x4d, 0xf1, 0xbf, 0xff, 0x5e, 0x7b, 0xf1,
    0x10, 0xbf, 0x0, 0xb, 0xf0, 0x0, 0xbf, 0x0,
    0xb, 0xf0, 0x0, 0xbf, 0x0, 0xb, 0xf0, 0x0,
    0xbf, 0x0, 0xb, 0xf0, 0x0, 0xbf,

    /* U+0032 "2" */
    0x0, 0x7d, 0xfd, 0x70, 0x0, 0xaf, 0x96, 0xbf,
    0x80, 0x3f, 0x70, 0x0, 0xdf, 0x0, 0x40, 0x0,
    0xa, 0xf1, 0x0, 0x0, 0x0, 0xde, 0x0, 0x0,
    0x0, 0x7f, 0x70, 0x0, 0x0, 0x5f, 0xb0, 0x0,
    0x0, 0x4f, 0xc0, 0x0, 0x0, 0x3f, 0xd1, 0x0,
    0x0, 0x3f, 0xd1, 0x0, 0x0, 0x2e, 0xf7, 0x55,
    0x55, 0x6, 0xff, 0xff, 0xff, 0xf2,

    /* U+0033 "3" */
    0xf, 0xff, 0xff, 0xf9, 0x0, 0x55, 0x55, 0xef,
    0x40, 0x0, 0x0, 0x9f, 0x60, 0x0, 0x0, 0x7f,
    0x80, 0x0, 0x0, 0x5f, 0xa0, 0x0, 0x0, 0x3f,
    0xff, 0xd7, 0x0, 0x2, 0xa4, 0x49, 0xf9, 0x0,
    0x0, 0x0, 0xb, 0xf1, 0x0, 0x0, 0x0, 0x8f,
    0x25, 0xb0, 0x0, 0xc, 0xf0, 0x3f, 0xd7, 0x6c,
    0xf7, 0x0, 0x3b, 0xef, 0xc5, 0x0,

    /* U+0034 "4" */
    0x0, 0x0, 0x3, 0xf7, 0x0, 0x0, 0x0, 0xd,
    0xf7, 0x0, 0x0, 0x0, 0x9f, 0xf7, 0x0, 0x0,
    0x4, 0xf8, 0xf7, 0x0, 0x0, 0x1e, 0xa2, 0xf7,
    0x0, 0x0, 0xae, 0x12, 0xf7, 0x0, 0x6, 0xf4,
    0x2, 0xf7, 0x0, 0x1f, 0x91, 0x13, 0xf7, 0x10,
    0x8f, 0xff, 0xff, 0xff, 0xf1, 0x24, 0x44, 0x45,
    0xf9, 0x40, 0x0, 0x0, 0x2, 0xf7, 0x0, 0x0,
    0x0, 0x2, 0xf7, 0x0,

    /* U+0035 "5" */
    0x1, 0xff, 0xff, 0xff, 0x10, 0x3f, 0x85, 0x55,
    0x50, 0x5, 0xf3, 0x0, 0x0, 0x0, 0x7f, 0x0,
    0x0, 0x0, 0x9, 0xfb, 0xff, 0xb2, 0x0, 0xbf,
    0x94, 0x7f, 0xe0, 0x1, 0x40, 0x0, 0x6f, 0x60,
    0x0, 0x0, 0x2, 0xf9, 0x0, 0x0, 0x0, 0x2f,
    0x90, 0xb9, 0x0, 0x7, 0xf5, 0x8, 0xfa, 0x68,
    0xfd, 0x0, 0x6, 0xdf, 0xe9, 0x10,

    /* U+0036 "6" */
    0x0, 0x0, 0x5f, 0x90, 0x0, 0x0, 0x1e, 0xe0,
    0x0, 0x0, 0xc, 0xf4, 0x0, 0x0, 0x7, 0xf9,
    0x0, 0x0, 0x2, 0xfd, 0x0, 0x0, 0x0, 0xbf,
    0xef, 0xfd, 0x50, 0xf, 0xfa, 0x56, 0xdf, 0x43,
    0xfb, 0x0, 0x1, 0xfb, 0x2f, 0x80, 0x0, 0xd,
    0xd0, 0xec, 0x0, 0x1, 0xfb, 0x6, 0xfb, 0x67,
    0xef, 0x30, 0x5, 0xcf, 0xeb, 0x30,

    /* U+0037 "7" */
    0x5f, 0xff, 0xff, 0xff, 0x71, 0x66, 0x66, 0x6a,
    0xf4, 0x0, 0x0, 0x0, 0xcd, 0x0, 0x0, 0x0,
    0x4f, 0x60, 0x0, 0x0, 0xb, 0xe0, 0x0, 0x0,
    0x2, 0xf7, 0x0, 0x0, 0x0, 0xaf, 0x10, 0x0,
    0x0, 0x1f, 0x90, 0x0, 0x0, 0x8, 0xf2, 0x0,
    0x0, 0x0, 0xfb, 0x0, 0x0, 0x0, 0x7f, 0x40,
    0x0, 0x0, 0xe, 0xd0, 0x0, 0x0,

    /* U+0038 "8" */
    0x0, 0x4c, 0xff, 0xb2, 0x0, 0x4, 0xfc, 0x66,
    0xee, 0x10, 0xa, 0xf1, 0x0, 0x4f, 0x70, 0xb,
    0xf0, 0x0, 0x2f, 0x80, 0x5, 0xf9, 0x12, 0xbf,
    0x20, 0x0, 0x9f, 0xff, 0xf6, 0x0, 0x7, 0xf9,
    0x45, 0xbf, 0x40, 0x1f, 0xb0, 0x0, 0xd, 0xd0,
    0x3f, 0x70, 0x0, 0xa, 0xf0, 0x1f, 0xc0, 0x0,
    0xe, 0xe0, 0x8, 0xfb, 0x66, 0xdf, 0x50, 0x0,
    0x6c, 0xff, 0xb4, 0x0,

    /* U+0039 "9" */
    0x0, 0x8d, 0xfe, 0x90, 0x0, 0xbf, 0x96, 0x8f,
    0xc0, 0x3f, 0x80, 0x0, 0x5f, 0x56, 0xf4, 0x0,
    0x1, 0xf9, 0x5f, 0x60, 0x0, 0x3f, 0x90, 0xee,
    0x52, 0x4d, 0xf7, 0x3, 0xef, 0xff, 0xff, 0x10,
    0x0, 0x33, 0x7f, 0x80, 0x0, 0x0, 0x2f, 0xd0,
    0x0, 0x0, 0xc, 0xf3, 0x0, 0x0, 0x7, 0xf7,
    0x0, 0x0, 0x3, 0xfc, 0x0, 0x0
};


/*---------------------
 *  GLYPH DESCRIPTION
 *--------------------*/

static const lv_font_fmt_txt_glyph_dsc_t glyph_dsc[] = {
    {.bitmap_index = 0, .adv_w = 0, .box_w = 0, .box_h = 0, .ofs_x = 0, .ofs_y = 0} /* id = 0 reserved */,
    {.bitmap_index = 0, .adv_w = 160, .box_w = 10, .box_h = 12, .ofs_x = 0, .ofs_y = 0},
    {.bitmap_index = 60, .adv_w = 110, .box_w = 5, .box_h = 12, .ofs_x = 0, .ofs_y = 0},
    {.bitmap_index = 90, .adv_w = 142, .box_w = 9, .box_h = 12, .ofs_x = 0, .ofs_y = 0},
    {.bitmap_index = 144, .adv_w = 143, .box_w = 9, .box_h = 12, .ofs_x = 0, .ofs_y = 0},
    {.bitmap_index = 198, .adv_w = 153, .box_w = 10, .box_h = 12, .ofs_x = 0, .ofs_y = 0},
    {.bitmap_index = 258, .adv_w = 151, .box_w = 9, .box_h = 12, .ofs_x = 0, .ofs_y = 0},
    {.bitmap_index = 312, .adv_w = 151, .box_w = 9, .box_h = 12, .ofs_x = 0, .ofs_y = 0},
    {.bitmap_index = 366, .adv_w = 144, .box_w = 9, .box_h = 12, .ofs_x = 0, .ofs_y = 0},
    {.bitmap_index = 420, .adv_w = 157, .box_w = 10, .box_h = 12, .ofs_x = 0, .ofs_y = 0},
    {.bitmap_index = 480, .adv_w = 150, .box_w = 9, .box_h = 12, .ofs_x = 0, .ofs_y = 0}
};

/*---------------------
 *  CHARACTER MAPPING
 *--------------------*/



/*Collect the unicode lists and glyph_id offsets*/
static const lv_font_fmt_txt_cmap_t cmaps[] =
{
    {
        .range_start = 48, .range_length = 10, .glyph_id_start = 1,
        .unicode_list = NULL, .glyph_id_ofs_list = NULL, .list_length = 0, .type = LV_FONT_FMT_TXT_CMAP_FORMAT0_TINY
    }
};

/*-----------------
 *    KERNING
 *----------------*/


/*Pair left and right glyphs for kerning*/
static const uint8_t kern_pair_glyph_ids[] =
{
    1, 8,
    2, 8,
    4, 2,
    4, 6,
    4, 8,
    4, 10,
    5, 2,
    5, 6,
    5, 8,
    5, 10,
    6, 2,
    6, 7,
    6, 8,
    6, 10,
    7, 2,
    7, 8,
    7, 10,
    8, 1,
    8, 5,
    8, 6,
    8, 7,
    8, 8,
    8, 9,
    9, 2,
    9, 8,
    9, 10,
    10, 4,
    10, 5,
    10, 6,
    10, 7,
    10, 8,
    10, 9
};

/* Kerning between the respective left and right glyphs
 * 4.4 format which needs to scaled with `kern_scale`*/
static const int8_t kern_pair_values[] =
{
    -8, -4, -5, -3, -6, -4, -5, -4,
    -12, -5, -5, -1, -8, -5, -13, -17,
    -8, -6, -23, -5, -16, 2, -5, -4,
    -10, -3, -2, -10, -2, -7, -7, -2
};

/*Collect the kern pair's data in one place*/
static const lv_font_fmt_txt_kern_pair_t kern_pairs =
{
    .glyph_ids = kern_pair_glyph_ids,
    .values = kern_pair_values,
    .pair_cnt = 32,
    .glyph_ids_size = 0
};

/*--------------------
 *  ALL CUSTOM DATA
 *--------------------*/

#if LVGL_VERSION_MAJOR == 8
/*Store all the custom data of the font*/
static  lv_font_fmt_txt_glyph_cache_t cache;
#endif

#if LVGL_VERSION_MAJOR >= 8
static const lv_font_fmt_txt_dsc_t font_dsc = {
#else
static lv_font_fmt_txt_dsc_t font_dsc = {
#endif
    .glyph_bitmap = glyph_bitmap,
    .glyph_dsc = glyph_dsc,
    .cmaps = cmaps,
    .kern_dsc = &kern_pairs,
    .kern_scale = 16,
    .cmap_num = 1,
    .bpp = 4,
    .kern_classes = 0,
    .bitmap_format = 0,
#if LVGL_VERSION_MAJOR == 8
    .cache = &cache
#endif
};



/*-----------------
 *  PUBLIC FONT
 *----------------*/

/*Initialize a public general font descriptor*/
#if LVGL_VERSION_MAJOR >= 8
const lv_font_t game_2048_font_16 = {
#else
lv_font_t game_2048_font_16 = {
#endif
    .get_glyph_dsc = lv_font_get_glyph_dsc_fmt_txt,    /*Function pointer to get glyph's data*/
    .get_glyph_bitmap = lv_font_get_bitmap_fmt_txt,    /*Function pointer to get glyph's bitmap*/
    .line_height = 12,          /*The maximum line height required by the font*/
    .base_line = 0,             /*Baseline measured from the bottom of the line*/
#if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0)
    .subpx = LV_FONT_SUBPX_NONE,
#endif
#if LV_VERSION_CHECK(7, 4, 0) || LVGL_VERSION_MAJOR >= 8
    .underline_position = -1,
    .underline_thickness = 1,
#endif
    .dsc = &font_dsc,          /*The custom font data. Will be accessed by `get_glyph_bitmap/dsc` */
#if LV_VERSION_CHECK(8, 2, 0) || LVGL_VERSION_MAJOR >= 9
    .fallback = NULL,
#endif
    .user_data = NULL,
};



#endif /*#if GAME_2048_FONT_16*/

